local fuding = fk.CreateSkill({
  name = "kq__fuding",
})

fuding:addEffect(fk.AfterCardTargetDeclared,  {
  anim_type = "offensive",
  can_trigger = function (self, event, target, player, data)
    local room = player.room
    if target == player and player:hasSkill(fuding.name) and data.card
       and (data.card.type == Card.TypeBasic or data.card:isCommonTrick()) 
       and data.card.name ~= "jink" and data.card.name ~= "nullification" then
        if not table.contains(player:getTableMark("fuding-round"), data.card.trueName) then
            local use_events = room.logic:getEventsOfScope(GameEvent.UseCard, 1, function (e)
            local use = e.data
            if use.from == player and use.card.trueName == data.card.trueName then
                room:addTableMark(player, "fuding-round", data.card.trueName)
                return true
            end
            end, Player.HistoryRound)
            return (#use_events == 1 and use_events[1].data == data) or (#use_events == 0 and event == fk.CardResponding)
        end
    end

  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if data.card.name ~= "jink" or data.card.name ~= "nullification" then
      room:moveCardTo(data.card, Card.PlayerHand, player, fk.ReasonPrey, fuding.name, nil, true, player)
      player:showCards(data.card)
      if player.drank > 0 then
        if player:getMark("@@jiu") == 0 then
          room:addPlayerMark(player, "@@jiu")
        end
      end
      if player:getMark("@@jiu") > 0 then
          player.drank = 1
          room:setPlayerMark(player, "@@jiu", 0)
      end
      local to =data.tos
        if data.toCard then
            data.toCard = nil
        else
            data.tos = {}
        end
        room:useVirtualCard(data.card.name, nil, player, to, fuding.name)
    end
    local choice = room:askToChoice(target, {
        choices = {"本轮失去武将牌上的首个技能" , "将展示的牌置于牌堆顶"},
        skill_name = fuding.name
      })
    if choice == "本轮失去武将牌上的首个技能" then
        if player:getSkillNameList()[1] == "kq__mengming" then
            room:addPlayerMark(player, "@@kq__fuding_1")
        elseif player:getSkillNameList()[1] == "kq__fuding" then
          
            room:addPlayerMark(player, "@@kq__fuding_2")
        end
        room:handleAddLoseSkills(player, "-"..player:getSkillNameList()[1])
    else
        room:moveCardTo(data.card, Card.DrawPile, nil, fk.ReasonPut, fuding.name, nil, true, player)
    end
  end,
})

fuding:addEffect(fk.RoundEnd, {
  can_trigger = function(self, event, target, player, data)
    return player:getMark("@@kq__fuding_1") > 0 or player:getMark("@@kq__fuding_2") > 0
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if player:getMark("@@kq__fuding_1") > 0 then
        room:handleAddLoseSkills(player, "kq__mengming", nil, false, true)
    end
    if player:getMark("@@kq__fuding_2") > 0 then
        room:handleAddLoseSkills(player, "kq__fuding", nil, false, true)
    end
    room:setPlayerMark(player, "@@kq__fuding_1", 0)
    room:setPlayerMark(player, "@@kq__fuding_2", 0)
  end,
})




Fk:loadTranslationTable {
["kq__fuding"] = "赴鼎",
[":kq__fuding"] = "锁定技，每轮每种牌名限一次，你使用基本牌或普通锦囊牌指定目标角色时，改为展示此牌以视为使用之，且你选择一项：<br>"..
"1.本轮失去武将牌上的首个技能；<br>"..
"2.将展示的牌置于牌堆顶。",
["$kq__fuding1"] = "大抱薪继于沧海，效精卫衔石，期泽国成桑田之日。",
["$kq__fuding2"] = "舍身求仁，非古来志士之专，维何惜一死。",
["@@kq__fuding_1"] = "失去 蒙明",
["@@kq__fuding_2"] = "失去 赴鼎",
["@@jiu"] = "醉酒状态"
}

return fuding